package com.ggh.jinjilive.ui.mine.zhubo.adapter;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.ggh.jinjilive.R;
import com.ggh.jinjilive.databinding.ItemLiushuiDetailsBinding;
import com.ggh.jinjilive.databinding.ItemZhuboStatementBinding;
import com.ggh.jinjilive.listener.AddItemOnClickListener;
import com.ggh.jinjilive.mobile.mine.zhubo.LiuShuiDetailsModel;

import java.util.List;

public class LiuShuiDetailsAdapter extends RecyclerView.Adapter<LiuShuiDetailsAdapter.ItemViewHolder> {


    private List<LiuShuiDetailsModel> liuShuiDetailsModelList;

    public void add(List<LiuShuiDetailsModel> liuShuiDetailsModelList) {
        this.liuShuiDetailsModelList.addAll(liuShuiDetailsModelList);
        notifyDataSetChanged();
    }

    public void setAdd(List<LiuShuiDetailsModel> liuShuiDetailsModelList) {
        this.liuShuiDetailsModelList = liuShuiDetailsModelList;
        notifyDataSetChanged();
    }

    private AddItemOnClickListener addItemOnClickListener;

    public void setAddItemOnClickListener(AddItemOnClickListener addItemOnClickListener) {
        this.addItemOnClickListener = addItemOnClickListener;
    }

    @NonNull
    @Override
    public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        ItemLiushuiDetailsBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_liushui_details, parent, false);
        return new ItemViewHolder(binding);
    }

    @Override
    public void onBindViewHolder(@NonNull ItemViewHolder holder, int position) {
        LiuShuiDetailsModel liuShuiDetailsModel = liuShuiDetailsModelList.get(position);
        if(null != liuShuiDetailsModel){
            //钻石
            holder.binding.tvPrice.setText(liuShuiDetailsModel.getPrice());
            //送礼人
            holder.binding.tvTitle.setText(liuShuiDetailsModel.getTitle());
            //日期
            holder.binding.tvCreateTime.setText(liuShuiDetailsModel.getCreate_time());
        }
    }

    @Override
    public int getItemCount() {
        return null == liuShuiDetailsModelList ? 0 : liuShuiDetailsModelList.size();
    }

    public class ItemViewHolder extends RecyclerView.ViewHolder {
        ItemLiushuiDetailsBinding binding;

        public ItemViewHolder(@NonNull ItemLiushuiDetailsBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }
    }
}
